

    \filetitle{specrange}{Time series specific range}{tseries/specrange}

	\paragraph{Syntax}

\begin{verbatim}
Rng = specrange(X,S)
\end{verbatim}

\paragraph{Input arguments}

\begin{itemize}
\item
  \texttt{X} {[} tseries {]} - Time series.
\item
  \texttt{S} {[} numeric \textbar{} \texttt{@all} {]} - Range
  specification; the output range \texttt{Rng} will be constructed from
  the first and the last element of \texttt{S} only.
\end{itemize}

\paragraph{Output arguments}

\begin{itemize}
\tightlist
\item
  \texttt{Rng} {[} numeric {]} - Date range constructed from \texttt{S}
  specific to time series \texttt{X}.
\end{itemize}

\paragraph{Description}

The time series specific range is constructed as
\texttt{startDate:endDate} where

\begin{itemize}
\item
  the start date \texttt{startDate} is \texttt{S(1)} if \texttt{S(1)} is
  a serial date number, or the start date of the input series \texttt{X}
  if \texttt{S(1)} is \texttt{Inf}, \texttt{-Inf}, or \texttt{@all};
\item
  the end date \texttt{endDate} is \texttt{S(end)} if \texttt{S(end)} is
  a serial date number, or the end date of the input series \texttt{X}
  if \texttt{S(end)} is \texttt{Inf}, or \texttt{@all}.
\end{itemize}

\paragraph{Example}

Create a time series from \texttt{2000Q1} to \texttt{2001Q4}

\begin{verbatim}
>> x = tseries( qq(2000,1):qq(2001,4), @rand );
\end{verbatim}

The function \texttt{specrange} returns the full range of the time
series when \texttt{S} is \texttt{Inf}

\begin{verbatim}
>> dat2str( specrange(x,Inf) )
ans = 
    Columns 1 through 6
    '2000Q1'    '2000Q2'    '2000Q3'    '2000Q4'    '2001Q1'    '2001Q2'
    Columns 7 through 8
    '2001Q3'    '2001Q4'
\end{verbatim}

or when \texttt{S} is \texttt{{[}-Inf,Inf{]}}

\begin{verbatim}
>> dat2str( specrange(x,[-Inf,Inf]) )
ans = 
    Columns 1 through 6
    '2000Q1'    '2000Q2'    '2000Q3'    '2000Q4'    '2001Q1'    '2001Q2'
    Columns 7 through 8
    '2001Q3'    '2001Q4'
\end{verbatim}

or when \texttt{S} is \texttt{@all}

\begin{verbatim}
>> dat2str( specrange(x,@all) )
ans = 
    Columns 1 through 6
    '2000Q1'    '2000Q2'    '2000Q3'    '2000Q4'    '2001Q1'    '2001Q2'
    Columns 7 through 8
    '2001Q3'    '2001Q4'
\end{verbatim}

A range from the start of the time series to a specific date is returned
when \texttt{S(1)} is \texttt{-Inf} and \texttt{S(end)} is that specific
end date:

\begin{verbatim}
>> dat2str( specrange(x,[-Inf,qq(2000,3)]) )
ans = 
    '2000Q1'    '2000Q2'    '2000Q3'
\end{verbatim}

A range from a specific date to the end of the time series is returned
when \texttt{S(1)} is that specific start date date, and \texttt{S(end)}
is \texttt{Inf}:

\begin{verbatim}
>> dat2str( specrange(x,[qq(2000,3),Inf]) )
ans = 
    '2000Q3'    '2000Q4'    '2001Q1'    '2001Q2'    '2001Q3'    '2001Q4'
\end{verbatim}


